//
//  FaceRecoH5Plugin.m
//  PCDBankSix
//
//  Created by APPLE on 2023/8/23.
//

#import "FaceRecoH5Plugin.h"
#import "PCDFaceRecoManager.h"

@implementation FaceRecoH5Plugin

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback{
    
    NSDictionary *dictData = (NSDictionary *)data;
    NSString *strCallback = dictData[@"success"];
    NSString *failCallback = dictData[@"fail"];
    
    [[PCDFaceRecoManager shareInstance] startFaceWithVC:context.viewController Type:veryFaceTypeFromWeb showTips:@"我行采集人脸信息仅用于登录、转账等实时交易场景中对您的身份进行核实" resultBlock:^(BOOL resultStatus, id  _Nullable resultInfo) {
        if (resultStatus) {
            evaluateJavaScriptOnMainThread(self, strCallback, [@{@"imagesEncrypt":resultInfo} JSONRepresentation]);
        }else {
            [PCDUtil toastMessage:resultInfo];
            evaluateJavaScriptOnMainThread(self, failCallback, [@{@"errCode":resultInfo} JSONRepresentation]);
        }
    }];
}

@end
